/*
 * BtreeNode.h
 *
 *  Created on: Oct 26, 2011
 *      Author: hxu
 */

#ifndef BTREENODE_H_
#define BTREENODE_H_

#include "TreeNode.h"

namespace Cxuh {

class BtreeNode: public Cxuh::TreeNode<int> {
	friend class Btree;
public:
	BtreeNode(int id1, char nodetype);
	BtreeNode(int id1, char nodetype, int x1, int y1, int z1);
	virtual ~BtreeNode();
	void setXY(int x1, int y1);
	void setXYZ(int x1, int y1, int z1);
	void setC(double c); // input cap seen by the predecessor, excluding the children
	void setR(double r); // output res seen by the successor, excluding the parent and preceding wire
	int getX() const;
	int getY() const;
	int getZ() const;
	virtual int getZ2() const;
	double getC() const;
	double getR() const;
	virtual double getD() const;
	double get_dmax() const;
	double get_dmin() const;

	void calc_path_delay(); // calculate the min and max path delay
	double get_in_cload() const;	// get the c load seen at the input of this node

	friend int operator-(const BtreeNode&, const BtreeNode&);
	friend std::ostream& operator<<(std::ostream&, BtreeNode& obj);

protected:
	BtreeNode* parent;
	BtreeNode* lchild, *rchild; // left and right children
	int x, y, z;
	double C; // input cap seen by the predecessor, excluding the children
	double R; // output res seen by the successor, excluding the parent and preceding wire
	std::string name;
	double dmin, dmax; // the min/max delay to its sinks
	void initBtreeNode(); // initialization
};

}

#endif /* BTREENODE_H_ */
